import numpy as np

np.random.seed(1)
x = np.random.randint(1, 10, size=30)   # random产生随机数

x = x.reshape(-1,3) # （行，列）已知需要3列，-1表示根据三列来自动分配多少行
print(x)
print('*'*60)
#print(x[0:10,1:2])  # 切片，0行到10行，1列到2列，含首不含尾

x[:,2][x[:,2]<=3]=0
print(x)
print('*'*60)

x[:,2][(x[:,2]>3) & (x[:,2]<=6)] = 1
print(x)
print('*'*60)

x[:,2][x[:,2]>6]=2
print(x)
print('*'*60)

y_train = x[:,2]
x_train = x[:,0:2]


# 分类未0的样本
print('*'*15,'分类为0的样本','*'*15)
print(x_train[y_train==0])
# 分类未1的样本
print('*'*15,'分类为1的样本','*'*15)
print(x_train[y_train==1])
# 分类未2的样本
print('*'*15,'分类为2的样本','*'*15)
print(x_train[y_train==2])
